-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not apply a refactoring if it drops comments #101
Conversation
6203bdf
to
8e58831
Compare
Hi @zliu41 , not sure if this is related with a broken test case in hls using apply-refact head:
The hint is not applied but in previous runs using 4fbd3a3 with the same hls code, the test was succesful (so it applied the hint and preserved comments) The code for ghc-8.6.5 uses the old I am gonna use 4fbd3a3 again to see if the test case is green again and will confirm here the result |
Well i did not test a inline comment inside the code being refactored:
So maybe the refactoring would remove it (i will add that case in my test suite). If that is the case, maybe the code could detect if the comment is inside the source span being refactored and no outside, to no apply the hint |
Mmm reviewing the test cases here i think Not sure if that is which i would expect, i guess the code is being conservative, as the comment could refer the tokens being removed in some way, or is there another reason? |
After use 4fbd3a3 with haskell/haskell-language-server@7144430 the test is succesful again: https://github.com/haskell/haskell-language-server/pull/635/checks?check_run_id=1693884153 I'am gonna add a comment inside refactored code in the test case for completeness |
The test case has failed with
So 4fbd3a3 preserve comments inside the refactored code but it removed one existent whitespace before The file being tested is -- comment before header
module ApplyRefact6 where
{-# standalone annotation #-}
-- standalone comment
-- | haddock comment
f = {- inline comment -} ({- inline comment inside refactored code -}1) -- ending comment
-- final comment |
@jneira Thanks for reporting these problems! In the I'll take a closer look at the |
@jneira I have fixed the The |
As a result, we no longer filter overlapping hints out before applying them; instead, we filter them out as we go. Because if refactoring A overlaps with refactoring B, but A isn't applied due to dropping comments, then B can still be applied.
Fixes #93